package GUI;

import 试题和试卷.paper;

import javax.swing.*;
import java.awt.*;

public class detailWindow extends JFrame {
    JPanel panel;

    JLabel successLab=new JLabel();
    JLabel numberLab=new JLabel();
    JLabel timeLab=new JLabel();
    JLabel selLab=new JLabel();
    JLabel defLab=new JLabel();
    JLabel filLab=new JLabel();
    JLabel subLab=new JLabel();

    public detailWindow(){}

    public detailWindow(paper currentpaper){
        this.setSize(200,320);
        Font bigFont = new Font("sanserif",Font.PLAIN,15);
        panel = new JPanel();
        panel.setLayout(null);
        Runnable r = () -> {
            String name=currentpaper.getName();
            int questionNumber=currentpaper.getQuestionNumber();
            int def=currentpaper.getDefinitionNumber(); //该句出错！！！
            int fil=currentpaper.getFillingBlankNumber();
            int sel=currentpaper.getSelectionNumber();
            int sub=currentpaper.getsubjectiveNumber();
            successLab.setText(name);
            successLab.setFont(bigFont);
            timeLab.setText("时间："+currentpaper.getTime()+"min");
            numberLab.setText("试题数目："+questionNumber);
            selLab.setText("选择题数目："+sel);
            defLab.setText("判断题数目："+def);
            filLab.setText("填空题数目："+fil);
            subLab.setText("简答题数目："+sub);


            successLab.setOpaque(true);
            successLab.setBorder(BorderFactory.createLineBorder(Color.darkGray));
            timeLab.setOpaque(true);
            timeLab.setBorder(BorderFactory.createLineBorder(Color.darkGray));
            numberLab.setOpaque(true);
            numberLab.setBorder(BorderFactory.createLineBorder(Color.darkGray));
            selLab.setOpaque(true);
            selLab.setBorder(BorderFactory.createLineBorder(Color.darkGray));
            defLab.setOpaque(true);
            defLab.setBorder(BorderFactory.createLineBorder(Color.darkGray));
            filLab.setOpaque(true);
            filLab.setBorder(BorderFactory.createLineBorder(Color.darkGray));
            subLab.setOpaque(true);
            subLab.setBorder(BorderFactory.createLineBorder(Color.darkGray));

            panel.setSize(detailWindow.this.getSize());

            successLab.setBounds(40,30,100,30);
            timeLab.setBounds(40,70,100,20);
            numberLab.setBounds(40,100,100,20);
            selLab.setBounds(40,130,100,20);
            defLab.setBounds(40,160,100,20);
            filLab.setBounds(40,190,100,20);
            subLab.setBounds(40,220,100,20);


            panel.add(successLab);
            panel.add(numberLab);
            panel.add(timeLab);
            panel.add(selLab);
            panel.add(defLab);
            panel.add(filLab);
            panel.add(subLab);

            detailWindow.this.setContentPane(panel);
            detailWindow.this.setLocationRelativeTo(null);//居中

            detailWindow.this.setTitle("在线考试平台");
            detailWindow.this.setVisible(true);
            //this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        };
        Thread tim=new Thread(r);
        tim.run();
    }

}
